﻿using System;
using System.Drawing;
using System.Windows.Forms;

namespace SalaryReport.Core.Excel
{
    [Serializable]
    public class ExcelColumn : ExcelItem
    {
        private readonly ComboBox cbColumn;

        public ExcelColumnName Column
        {
            get { return (ExcelColumnName) cbColumn.SelectedItem; }
            set { cbColumn.SelectedItem = value; }
        }

        public ExcelColumn()
        {
            cbColumn = new ComboBox
                           {
                               Width = boxNumSize,
                               Location = new Point(btnSize + boxSize * 2 + margin * 4, margin)
                           };
            var names = Enum.GetValues(typeof (ExcelColumnName));
            foreach (var name in names)
            {
                cbColumn.Items.Add(name);
            }
            cbColumn.SelectedItem = ExcelColumnName.A;
            container.Controls.Add(cbColumn);
        }

        public ExcelColumn(bool isMandatory)
            : this()
        {
            IsMandatory = isMandatory;
            btnRemove.Visible = !isMandatory;
        }
    }
}